import { Node } from './Node'
export const VERSION = '0.4.6'
export const NAME = 'jsMind'
export const ANTHER = 'hizzgdev@163.com'
export interface JMOptions {
    container: string,         // [必选] 容器的ID
    editable?: boolean,       // 是否启用编辑
    theme?: string,           // 主题
    mode?: 'full' | 'side',           // 显示模式
    support_html?: boolean,    // 是否支持节点里的HTML元素
    view?:{
        hmargin: number,        // 思维导图距容器外框的最小水平距离
        vmargin: number,         // 思维导图距容器外框的最小垂直距离
        line_width: number,       // 思维导图线条的粗细
        line_color: string   // 思维导图线条的颜色
    },
    layout?:{
        hspace: number,          // 节点之间的水平间距
        vspace: number,          // 节点之间的垂直间距
        pspace: number           // 节点收缩/展开控制器的尺寸
    },
    default_event_handle?:{
        enable_mousedown_handle?: boolean,
        enable_click_handle?: boolean,
        enable_dblclick_handle?: boolean
    },
    shortcut?: ShorcutOptions
};

export interface LayoutOptions {
    mode?: 'full' | 'side',
    hspace?: number,          // 节点之间的水平间距
    vspace?: number,          // 节点之间的垂直间距
    pspace?: number           // 节点收缩/展开控制器的尺寸
}

export interface ViewOptions {
    container: string | HTMLElement,
    support_html?: boolean,
    hmargin?: number,        // 思维导图距容器外框的最小水平距离
    vmargin?: number,         // 思维导图距容器外框的最小垂直距离
    line_width?: number,       // 思维导图线条的粗细
    line_color?: string   // 思维导图线条的颜色
}
export interface ShorcutOptions {
    enable?: boolean,        // 是否启用快捷键
    handles?: any,         // 命名的快捷键事件处理器
    mapping?:{           // 快捷键映射
        addchild?   : number,    // <Insert>
        addbrother? : number,    // <Enter>
        editnode?   : number,   // <F2>
        delnode?    : number,    // <Delete>
        toggle?     : number,    // <Space>
        left?       : number,    // <Left>
        up?         : number,    // <Up>
        right?      : number,    // <Right>
        down?       : number,    // <Down>
    } 
}

export interface Bound {
    s?: number,
    n?: number,
    w?: number,
    e?: number,
}

 export enum Direction {
    Left = -1,
    Center = 0,
    Right = 1
 }

 export enum EventType {
     Show = 1,
     Resize,
     Edit,
     Select
 }

 export interface NodeData {
     view?: {
        element?: HTMLElement,
        expander?: HTMLElement,
        width?: number,
        height?: number,
        abs_x?: number,
        abs_y?: number,
        _saved_location?: Location
     }
     layout?: {
        direction?: Direction,
        side_index?: any,
        offset_x?: any,
        offset_y?: any,
        outer_height?: any,
        left_nodes?: Node[],
        right_nodes?: Node[],
        outer_height_left?: any,
        outer_height_right?: any,
        visible?: boolean
     }
 }

 export interface Location {
     x?: number,
     y?: number
 }
 export interface Size {
     w?: number,
     h?: number
 }

 /**
  * node
  */
 export interface NodeTreeFormatMeta {
    meta?: {
        name?: string,
        author?: string,
        version?: string
    },

    format?: 'node_tree',

    data?: NodeTreeFormatData 
}

 export interface NodeTreeFormatData {
    id: string,
    topic: string,
    children?: NodeTreeFormatData[],
    direction?: 'left' | 'right' | 'center' | Direction,
    expanded?: boolean,
    [key: string]: any
 }

 export interface NodeArrayFormatMeta {
    meta?: {
        name?: string,
        author?: string,
        version?: string
    },

    format?: 'node_array',

    data?: NodeArrayFormatData[] 

 }

 export interface NodeArrayFormatData {
    id: string,
    topic: string,
    isroot?: boolean,
    parentid?: string,
    direction?: 'left' | 'center' | 'right' | Direction,
    [key: string]: any
 }